package cn.how2j;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

import cn.how2j.db.DBSConn;
import cn.hutool.core.util.RandomUtil;

public class MyMessageListener implements MessageListener {

	String name = "consumer-"+ RandomUtil.randomString(5);
	public  MyMessageListener() {
		System.out.println(name + " started");
	}
	
    public void onMessage(Message message) {
        TextMessage textMessage=(TextMessage)message;        
        try {
            System.out.println(name+" 接收到消息："+textMessage.getText());
            File file=new File("Person.xlsx");
    		ReadXLSX r=new ReadXLSX();
    		List l=r.getXlsxData(file);
    		Iterator<Person> p=l.iterator();
    		   DBSConn dbsconn=new DBSConn();
       	   
    		while (p.hasNext()) {
    			System.out.print(p.next().getName());
    			Person p1=p.next();
    			 dbsconn.dbsConn(p1);
    		}

//        
            
            
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}